# -*- coding: utf-8 -*-
from __future__ import unicode_literals
class URIFormatter(object):
    """Documentation goes here."""
    def __init__(self, *formatters, **kwargs):
        self._formatters = dict(formatters)

    def format(self, parseresult):
        formatter = self.formatterfor(parseresult.getName())
        if formatter:
            return formatter(dict(parseresult))
        else:
            return None

    def addformatter(self, key, func):
        self._formatters[key] = func

    def formatterfor(self, key):
        if key in self._formatters:
            return self._formatters[key]
        else:
            return None
